<!--
  To change this license header, choose License Headers in Project Properties.
  To change this template file, choose Tools | Templates
  and open the template in the editor.
-->

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
    <head>
        <meta name="layout" content="frontend">
        <script src="${resource(dir: 'js',file: 'bootbox.min.js')}"></script>
    </head>
    <body>
        <g:form action="queryResult">
            <div class="fieldcontain">
                <label>僅提供最近一年資訊</label>
            </div>
            <div class="fieldcontain">
                <label>開始日期</label>
                <input name="dateStart" value="" size="40" />　<span>格式：2015/2/9</span>
            </div>
            <div class="fieldcontain">
                <label>結束日期</label>
                <g:textField name="dateEnd" value="" size="40" />　<span>格式：2015/2/9</span>
            </div>

            <div class="fieldcontain">
                <label>活動類型</label>
                <g:select id="kind" name="kind.id" from="${code.Kind.list()}" optionKey="id" value="" noSelection="['':'']"/>
            </div>
            <div class="fieldcontain">
                <label></label><g:checkBox name="registerLeft" value="0" checked="false" />　未額滿<br/>
                <label></label><g:checkBox name="registerOpen" value="0" checked="false"/>　可報名<br/>
            </div>
            <div class="fieldcontain">
                <label></label><g:submitButton name="regEvents" value="查詢" class="btn btn-primary btn-sm" />
                <span id="error" style="color:red;display:none">　最少需選一場次！</span>
            </div>
        </g:form>
        <g:if test="${flash.message}">
            <div class="message" role="status">${flash.message}</div>
        </g:if>
        <!--<p>單場次活動，可勾選「多活動報名」後報名，多場次請點「我要報名」報名</p>-->
        <g:if test="${serialInstanceTotal > 0}">
        <table>
            <thead>
                <tr>
                    <!-- <th>多活動報名</th> -->
                    <th>狀態</th>
                    <th>活動名稱</th>
                    <th>場次數量</th>
                    <th>時間起迄</th>
                    <th>已報/可報/候補名額</th>
                    <th>報名起迄</th>
                    <th>詳細資料</th>
                </tr>
            </thead>
            <tbody>
                <g:each in="${serialInstanceList}" status="i" var="serial">
                    <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
                        <!-- <td><g:if test="${serial.eventCounts == 1}"><g:checkBox name="reg" value="${serial.id}" checked="false" /></g:if></td> -->
                        <td>${serial.status}</td>
                        <td>${serial.name}</td>
                        <td>${serial.eventCounts}</td>
                        <td>${formatDate(format:"MM/dd",date:serial.dateStart)} ~ ${formatDate(format:"MM/dd",date:serial.dateEnd)}</td>
                        <td>${serial.registerQty}/${serial.capacityQty}/${serial.standbyQty}</td>
                        <td>${formatDate(format:"MM/dd",date:serial.regStart)} ~ ${formatDate(format:"MM/dd",date:serial.regEnd)}</td>
                        <td>

                            <g:if test="${serial.status == "尚可報名"}">
                                <g:link action="serialDetail" id="${serial.id}">我要報名</g:link>
                            </g:if>
                            <g:elseif test="${serial.status == "候補報名"}">
                                <g:link action="serialDetail" id="${serial.id}">我要報名</g:link>
                            </g:elseif>
                            <g:else>
                                <g:link action="serialDetail" id="${serial.id}">顯示</g:link>
                            </g:else>

                        </td>

                        </tr>
                </g:each>
            </tbody>
        </table>
        <!--<div class="pagination">-->
            <!--<//m:paginate total="${serialInstanceTotal}" />-->
        <!--<m:paginate total="${serialInstanceTotal}" />-->
        <!--</div>-->
        </g:if>
    </body>
</html>
